package ONLINE_EXAM;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class baidu2 {
    //不区分大小写 统计单词的频率 以句号划分
    //对每个分句采用同样操作 分词-转化小写-用hashmap统计
    static HashMap<String,Integer> map = new HashMap<>();//存小写与频率
    static HashMap<String,String> map_index = new HashMap<>();//存小写与对应的原型
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str ;
        while ((str = br.readLine())!= null){
            String[] sentences = str.split(".");
            for (String s:sentences){
                helper(s);
            }

            List<Map.Entry<String,Integer>> list  = new ArrayList<>(map.entrySet());

            Collections.sort(list, new Comparator<Map.Entry<String, Integer>>() {
                @Override
                public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
                    if (o2.getValue()-o1.getValue() == 0){
                        return o1.getKey().compareTo(o2.getKey());
                    }else {
                        return o2.getValue()-o1.getValue();
                    }
                }
            });

            String tep = map_index.get(list.get(0).getKey());
            System.out.print(tep+" "+list.get(0).getValue());


        }
    }
    //对分句操作
    public static void helper(String s){
        String[] words = s.split(" ");

        //再借助一个map 存所有第一个出现的词语的原行
        for (String word:words){
            String temWord = word;//原型
            word = word.toLowerCase();
            if (map.containsKey(word)){
                map.put(word,map.get(word)+1);
            }else {
                map.put(word,1);
                map_index.put(word,temWord);
            }

        }

    }
}
